package com.sinosoft.cnmuseum.servlets;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;

import com.sinosoft.cnmuseum.dao.BaseDao;
import com.sinosoft.cnmuseum.dao.MbXtglJsglDao;
import com.sinosoft.cnmuseum.dao.MbXtglJsqxgxDao;
import com.sinosoft.cnmuseum.dao.MbXtglQxglDao;
import com.sinosoft.cnmuseum.dao.MbXtglRyjsfpDao;
import com.sinosoft.cnmuseum.entity.MbXtglJsgl;
import com.sinosoft.cnmuseum.entity.MbXtglJsqxgx;
import com.sinosoft.cnmuseum.entity.MbXtglQxgl;
import com.sinosoft.cnmuseum.entity.MbXtglRyjsfp;
import com.sinosoft.cnmuseum.utils.LogUtils;
import com.sinosoft.cnmuseum.utils.PageUtil;
import com.sinosoft.cnmuseum.utils.Status;
import com.sinosoft.cnmuseum.utils.StringUtils;
import com.sinosoft.commontools.annotated.TransAnnotation;
import com.sinosoft.commontools.annotated.rquestMethod;
import com.sinosoft.commontools.annotated.rquestMethod.ReqMode;
import com.sinosoft.commontools.record.Record;

/**
 * Title: MbXtglQxServlet
 * Description: 权限管理
 * @author WEWE
 * @date 2019年1月10日 下午2:37:30
 * @version 1.0
 */
public class MbXtglQxServlet {
  private static Logger logger = Logger.getLogger(MbXtglQxServlet.class);

  /**
   * Description: 角色列表
   * @param request
   * @param response
   * @param data
   * @return
   */
  @rquestMethod(MethodNote = ReqMode.All)
  @TransAnnotation(isTrans=true)
  public Record getJsList(HttpServletRequest request, HttpServletResponse response, Record data) {
    Record result = new Record();
    try {
      MbXtglJsglDao dao = new MbXtglJsglDao();
      int pagenumber = data.getIntValue(Status.PAGENUMBER);// 获取当前页
      int pagesize = data.getIntValue(Status.PAGESIZE);// 获取每页多少条数据
      String countsql = "select count(zdbh) as count from " + MbXtglJsgl.MB_XTGL_JSGL_TABLE_NAME + " where " + MbXtglJsgl.JSZT + "=1 ";
      String sql = "select * from " + MbXtglJsgl.MB_XTGL_JSGL_TABLE_NAME + " where " + MbXtglJsgl.JSZT + "=1 ";
      String ordersql = " order by zdbh asc ";
      String limitsql = " limit ";

	    String jsmc = data.getStrValue(MbXtglJsgl.JSMC);
	    if (StringUtils.isNoEmpty(jsmc)) {
	      countsql += " and "+ MbXtglJsgl.JSMC + " like '%" + jsmc+"%' ";
	      sql += " and "+ MbXtglJsgl.JSMC + " like '%" + jsmc+"%' ";
	    }
	    String sfwzj = data.getStrValue(MbXtglJsgl.SFWZJ);
	    if (StringUtils.isNoEmpty(sfwzj)) {
	      countsql += " and "+ MbXtglJsgl.SFWZJ + " = '" + sfwzj+"' ";
	      sql += " and "+ MbXtglJsgl.SFWZJ + " = '" + sfwzj+"' ";
	    }
      
      //      String xm = data.getStrValue(MbXtglYhxx.XM);
      //      if (StringUtils.isNoEmpty(xm)) {
      //        countsql += " and "+ MbXtglYhxx.XM + " = '" + xm;
      //        sql += " and "+ MbXtglYhxx.XM + " = '" + xm;
      //      }
      logger.info("CSQL:" + countsql);
      List<Record> countlist = dao.getBySql(countsql);
      int total = countlist.get(0).getIntValue("count");
      PageUtil page = new PageUtil(pagenumber, pagesize, total);
      limitsql += page.getStart()+","+pagesize;
      logger.info("SQL:" + sql+ordersql+limitsql);
      List<Record> list = dao.getBySql(sql+ordersql+limitsql);
      // 组装数据
      result.add(Status.ROWS, list);
      result.add(Status.TOTAL, total);
      result.add(Status.PAGENUMBER, pagenumber);
      result.add(Status.PAGESIZE, pagesize);
      result.add(Status.PAGETOTAL, page.getPagetotal());
      // 返回接口调用成功标识
      result.add(Status.SATUS,Status.OK);
    } catch (Exception e) {
      // 返回接口调用失败标识
      result.add(Status.SATUS,Status.FAILED);
      // 返回接口调用失败信息，需要自己添加
      result.add(Status.MSG,"查询失败！");
    }
    // 接口返回Record对象，框架会自动封装返回给请求result对象中的数据
    return result;
  }
  
  
/**      
 * getJsListByPerson 根据用户获取
 * @author wangli
 * @param request
 * @param response
 * @param data
 * @return          
*/
  @rquestMethod(MethodNote = ReqMode.All)
public Record getJsListByPerson(HttpServletRequest request, HttpServletResponse response, Record data) {
	    Record result = new Record();
	    try {
	      MbXtglJsglDao dao = new MbXtglJsglDao();
	      int userid = data.getIntValue("zdbh");
	      int sfwzj = data.getIntValue("sfwzj");
	      int pagenumber = data.getIntValue(Status.PAGENUMBER);// 获取当前页
	      int pagesize = data.getIntValue(Status.PAGESIZE);// 获取每页多少条数据
	      String countsql = "select count(a.zdbh) as count from " + 
	    		  MbXtglJsgl.MB_XTGL_JSGL_TABLE_NAME + 
	    		  " a left join Mb_Xtgl_Ryjsfp b on a.zdbh=b.jsbm and b.rybm="+userid+" where " + 
	    		  MbXtglJsgl.JSZT + "=1 and sfwzj="+sfwzj;
	      String sql = "select a.*,b.rybm from " + 
	    		  MbXtglJsgl.MB_XTGL_JSGL_TABLE_NAME +
	      		  " a left join Mb_Xtgl_Ryjsfp b on a.zdbh=b.jsbm and b.rybm="+userid+" where " +
	    		  MbXtglJsgl.JSZT + "=1 and sfwzj="+sfwzj;
	      String ordersql = " order by a.zdbh asc ";
	      String limitsql = " limit ";

	      //      String xm = data.getStrValue(MbXtglYhxx.XM);
	      //      if (StringUtils.isNoEmpty(xm)) {
	      //        countsql += " and "+ MbXtglYhxx.XM + " = '" + xm;
	      //        sql += " and "+ MbXtglYhxx.XM + " = '" + xm;
	      //      }
	      logger.info("CSQL:" + countsql);
	      List<Record> countlist = dao.getBySql(countsql);
	      int total = countlist.get(0).getIntValue("count");
	      PageUtil page = new PageUtil(pagenumber, pagesize, total);
	      limitsql += page.getStart()+","+pagesize;
	      logger.info("SQL:" + sql+ordersql+limitsql);
	      List<Record> list = dao.getBySql(sql+ordersql+limitsql);
	      // 组装数据
	      result.add(Status.ROWS, list);
	      result.add(Status.TOTAL, total);
	      result.add(Status.PAGENUMBER, pagenumber);
	      result.add(Status.PAGESIZE, pagesize);
	      result.add(Status.PAGETOTAL, page.getPagetotal());
	      // 返回接口调用成功标识
	      result.add(Status.SATUS,Status.OK);
	    } catch (Exception e) {
	      // 返回接口调用失败标识
	      result.add(Status.SATUS,Status.FAILED);
	      // 返回接口调用失败信息，需要自己添加
	      result.add(Status.MSG,"查询失败！");
	    }
	    // 接口返回Record对象，框架会自动封装返回给请求result对象中的数据
	    return result;
	  }

  /**
   * Description: 权限列表
   * @param request
   * @param response
   * @param data
   * @return
   */
  @rquestMethod(MethodNote = ReqMode.All)
  @TransAnnotation(isTrans=true)
  @Deprecated
  public Record getQxList(HttpServletRequest request, HttpServletResponse response, Record data) {
    Record result = new Record();
    try {
      MbXtglQxglDao dao = new MbXtglQxglDao();
      int pagenumber = data.getIntValue(Status.PAGENUMBER);// 获取当前页
      int pagesize = data.getIntValue(Status.PAGESIZE);// 获取每页多少条数据
      String countsql = "select count(zdbh) as count from " + MbXtglQxgl.MB_XTGL_QXGL_TABLE_NAME + " where " + MbXtglQxgl.QXZT + "=1 ";
      String sql = "select *,0 as xzzt from " + MbXtglQxgl.MB_XTGL_QXGL_TABLE_NAME + " where " + MbXtglQxgl.QXZT + "=1 ";
      String ordersql = " order by zdbh asc ";
      String limitsql = " limit ";

      //      String xm = data.getStrValue(MbXtglYhxx.XM);
      //      if (StringUtils.isNoEmpty(xm)) {
      //        countsql += " and "+ MbXtglYhxx.XM + " = '" + xm;
      //        sql += " and "+ MbXtglYhxx.XM + " = '" + xm;
      //      }
      logger.info("CSQL:" + countsql);
      List<Record> countlist = dao.getBySql(countsql);
      int total = countlist.get(0).getIntValue("count");
      PageUtil page = new PageUtil(pagenumber, pagesize, total);
      limitsql += page.getStart()+","+pagesize;
      logger.info("SQL:" + sql+ordersql+limitsql);
      List<Record> list = dao.getBySql(sql+ordersql+limitsql);
      // 组装数据
      result.add(Status.ROWS, list);
      result.add(Status.TOTAL, total);
      result.add(Status.PAGENUMBER, pagenumber);
      result.add(Status.PAGESIZE, pagesize);
      result.add(Status.PAGETOTAL, page.getPagetotal());
      // 返回接口调用成功标识
      result.add(Status.SATUS,Status.OK);
    } catch (Exception e) {
      // 返回接口调用失败标识
      result.add(Status.SATUS,Status.FAILED);
      // 返回接口调用失败信息，需要自己添加
      result.add(Status.MSG,"查询失败！");
    }
    // 接口返回Record对象，框架会自动封装返回给请求result对象中的数据
    return result;
  }
  
  /**
   * Description: 权限列表
   * @param request
   * @param response
   * @param data
   * @return
   */
  @rquestMethod(MethodNote = ReqMode.All)
  @TransAnnotation(isTrans=true)
  public Record getQxTree(HttpServletRequest request, HttpServletResponse response, Record data) {
    Record result = new Record();
    try {
    	String zdbh = data.getStrValue("zdbh");
      List<Record> tree = new ArrayList<Record>();
      MbXtglQxglDao dao = new MbXtglQxglDao();
      String sql0 = "SELECT * FROM view_mb_xtgl_qxgl WHERE pid is null order BY id";
      List<Record> qxmcs = dao.getBySql(sql0);
      for (Record qxmc : qxmcs) {
        String name = qxmc.getStrValue("name");
        Record br = new Record();
        br.add("name", name);
        br.add("id", name);
        br.add("pId", 0);
        tree.add(br);
      }
      String sql1 = "SELECT * FROM view_mb_xtgl_qxgl WHERE pid is not null";
      List<Record> childlist = dao.getBySql(sql1);
      List<Integer> sellist = dao.getCheckId(zdbh);
      if(sellist!=null&&sellist.size()>0){
    	  for(Record child:childlist){
    		  int id = child.getIntValue("id");
    		  if(sellist.contains(id)){
    			  child.add("checked", true);
    		  }
    	  }
      }
      
      tree.addAll(childlist);
      // 返回接口调用成功标识
      result.add(Status.ROWS, tree);
      result.add(Status.SATUS,Status.OK);
    } catch (Exception e) {
      // 返回接口调用失败标识
      result.add(Status.SATUS,Status.FAILED);
      // 返回接口调用失败信息，需要自己添加
      result.add(Status.MSG,"查询失败！");
    }
    // 接口返回Record对象，框架会自动封装返回给请求result对象中的数据
    return result;
  }

  /**
   * Description: 分配权限，一个角色，多个权限
   * @param request
   * @param response
   * @param data
   * @return
   */
  @rquestMethod(MethodNote = ReqMode.All)
  @TransAnnotation(isTrans=true)
  public Record assignQx(HttpServletRequest request, HttpServletResponse response, Record data) {
    Record result = new Record();
    result.add(Status.SATUS,Status.OK);
    try {
      String qxbms = data.getStrValue("qxbms");
      String[] qxbmList = qxbms.split(",");
      String jsbm = data.getStrValue(MbXtglJsqxgx.JSBM);
      MbXtglJsqxgxDao dao = new MbXtglJsqxgxDao();
      Record oldjsqxgx = new Record();
      oldjsqxgx.add(MbXtglJsqxgx.JSBM, jsbm);
      List<Record> oldlist = dao.getListByProperty(oldjsqxgx);
      if(oldlist!=null&&oldlist.size()>0){
      	dao.delete(oldlist);
      }
      for (String qxbm : qxbmList) {
		Record jsqxgx = new Record();
		jsqxgx.add(MbXtglJsqxgx.JSBM, jsbm);
		jsqxgx.add(MbXtglJsqxgx.QXBM, qxbm);
		if(!dao.insert(jsqxgx)){
			throw new Exception("插入权限列表失败！");
		}
      }
    } catch (Exception e) {
      e.printStackTrace();
      logger.error(e.getMessage());
      // 事务回滚
      result.add(Status.SATUS, Status.FAILED);
    }
    return result;
  }

  /**
   * Description: 角色的权限列表
   * @param request
   * @param response
   * @param data
   * @return
   */
  @rquestMethod(MethodNote = ReqMode.All)
  @TransAnnotation(isTrans=true)
  public Record getQx(HttpServletRequest request, HttpServletResponse response, Record data) {
    Record result = new Record();
    try {
      String jsbm = data.getStrValue("zdbh");
      MbXtglQxglDao dao = new MbXtglQxglDao();
      StringBuffer sql = new StringBuffer("select * from " + MbXtglQxgl.MB_XTGL_QXGL_TABLE_NAME);
      sql.append(" where " + MbXtglQxgl.ZDBH + " in (");
      sql.append(" select " + MbXtglJsqxgx.QXBM + " from " + MbXtglJsqxgx.MB_XTGL_JSQXGX_TABLE_NAME);
      sql.append(" where " + MbXtglJsqxgx.JSBM + " = '" + jsbm + "')");
      logger.info("SQL:" + sql.toString());
      List<Record> list = dao.getBySql(sql.toString());
      result.add(Status.ROWS, list);
      result.add(Status.TOTAL, list.size());
      result.add(Status.SATUS,Status.OK);
    } catch (Exception e) {
      e.printStackTrace();
      logger.error(e.getMessage());
      // 事务回滚
      result.add(Status.SATUS, Status.FAILED);
    }
    return result;
  }

  @rquestMethod(MethodNote = ReqMode.All)
  @TransAnnotation(isTrans=true)
  public Record getQxByZj(HttpServletRequest request, HttpServletResponse response, Record data) {
    Record result = new Record();
    try {
      HttpSession session = request.getSession(false);
      //      int userid = 8;
      String userid = (String) session.getAttribute(Status.SESSION_USERID);
      MbXtglRyjsfpDao jdao = new MbXtglRyjsfpDao();
      List<Record> jsbms = jdao.getBySql("select * from " + MbXtglRyjsfp.MB_XTGL_RYJSFP_TABLE_NAME + " where " + MbXtglRyjsfp.RYBM + "='" + userid + "'");
      if (jsbms.isEmpty()) return result;
      String jsbm = jsbms.get(0).getStrValue(MbXtglRyjsfp.JSBM);
      MbXtglQxglDao dao = new MbXtglQxglDao();
      StringBuffer sql = new StringBuffer("select qxbm,qxmc from " + MbXtglQxgl.MB_XTGL_QXGL_TABLE_NAME);
      sql.append(" where " + MbXtglQxgl.QXBM + " in (");
      sql.append(" select " + MbXtglJsqxgx.QXBM + " from " + MbXtglJsqxgx.MB_XTGL_JSQXGX_TABLE_NAME);
      sql.append(" where " + MbXtglJsqxgx.JSBM + " = '" + jsbm + "')");
      logger.info("SQL:" + sql.toString());
      List<Record> list = dao.getBySql(sql.toString());
      result.add(Status.ROWS, list);
      result.add(Status.TOTAL, list.size());
      result.add(Status.SATUS,Status.OK);
    } catch (Exception e) {
      e.printStackTrace();
      logger.error(e.getMessage());
      // 事务回滚
      result.add(Status.SATUS, Status.FAILED);
    }
    return result;
  }

  @rquestMethod(MethodNote = ReqMode.All)
  @TransAnnotation(isTrans=true)
  public Record insert(HttpServletRequest request, HttpServletResponse response, Record data) {
    Record result = new Record();
    try{
		HttpSession session = request.getSession(false);
		String contributor = (String) session.getAttribute(Status.SESSION_USERID);// 责任者

		MbXtglJsglDao dao = new MbXtglJsglDao();
		Record jsgl = new Record();
		String jsbm = data.getStrValue(MbXtglJsgl.JSBM);
      //HashMap<String, Object> map = new HashMap<String, Object>(){{
      //  put(MbXtglJsgl.JSBM, jsbm);
      //}};
      //List<Record> list = dao.getListByProperty(map);
      //if (list == null || list.isEmpty()) {
        jsgl.add(MbXtglJsgl.JSBM, jsbm);
        jsgl.add(MbXtglJsgl.JSZT, 1);
        jsgl.add(MbXtglJsgl.JSMC, data.getStrValue(MbXtglJsgl.JSMC));
        jsgl.add(MbXtglJsgl.JSMS, data.getStrValue(MbXtglJsgl.JSMS));
        jsgl.add(MbXtglJsgl.SFWZJ, data.getStrValue(MbXtglJsgl.SFWZJ));
        if(data.getStrValue(MbXtglJsgl.SFWZJ).equals("1")){
        	jsgl.add(MbXtglJsgl.ZJLX, data.getStrValue(MbXtglJsgl.ZJLX));
        }//else{
        //	jsgl.add(MbXtglJsgl.ZJLX, data.getStrValue(MbXtglJsgl.ZJLX));
        //}
        if(dao.insert(jsgl)){
        	String jsmc = data.getStrValue(MbXtglJsgl.JSMC);
            LogUtils logUtils = new LogUtils();
            String desc =jsmc+LogUtils.MbXtglJsgl_INSERT_DESC;
            logUtils.addLog(String.valueOf(LogUtils.type_insert), LogUtils.model_qxgl, contributor, desc);	
        	
          result.add(Status.SATUS,Status.OK);
        }else{
          throw new Exception("插入信息失败！");
        }
      //} else {
      //  result.add(Status.SATUS, Status.FAILED);
      //  result.add(Status.MSG, "角色编码已存在");
      //}
    } catch (Exception e) {
      logger.error(e.getMessage());
      e.printStackTrace();
      // 事务回滚，事务模式下，此标识将使此次事务回滚
      result.add(Status.SATUS, Status.FAILED);
    }
    return result;
  }
  /**
   * Description: 角色详细
   * @param request
   * @param response
   * @param data
   * @return
   */
  @rquestMethod(MethodNote = ReqMode.All)
  public Record getDataById(HttpServletRequest request, HttpServletResponse response, Record data) {
    Record result = new Record();
    try {
      MbXtglJsglDao dao = new MbXtglJsglDao();
      Record jsgl = dao.getById(data.getIntValue(MbXtglJsgl.ZDBH));
      if(jsgl!=null){
        result.add(Status.ROWS, jsgl);
        result.add(Status.SATUS,Status.OK);
      }else{
        throw new Exception("查询信息失败！");
      }
    } catch (Exception e) {
      e.printStackTrace();
      logger.error(e.getMessage());
      result.add(Status.SATUS, Status.FAILED);
    }
    return result;
  }

  /**
   * Description: 更新角色
   * @param request
   * @param response
   * @param data
   * @return
   */
  @rquestMethod(MethodNote = ReqMode.All)
  @TransAnnotation(isTrans=true)
  public Record update(HttpServletRequest request, HttpServletResponse response, Record data) {
    Record result = new Record();
    try {
        HttpSession session = request.getSession(false);
        String contributor = (String) session.getAttribute(Status.SESSION_USERID);//责任者
        
      MbXtglJsglDao dao = new MbXtglJsglDao();
      Record jsgl = dao.getById(data.getIntValue(MbXtglJsgl.ZDBH));
      jsgl.add(MbXtglJsgl.JSMC, data.getStrValue(MbXtglJsgl.JSMC));
      jsgl.add(MbXtglJsgl.JSMS, data.getStrValue(MbXtglJsgl.JSMS));
      jsgl.add(MbXtglJsgl.SFWZJ, data.getStrValue(MbXtglJsgl.SFWZJ));
      if(data.getStrValue(MbXtglJsgl.SFWZJ).equals("1")){
      	jsgl.add(MbXtglJsgl.ZJLX, data.getStrValue(MbXtglJsgl.ZJLX));
      }else{
      	jsgl.add(MbXtglJsgl.ZJLX, "");
      }
      if(dao.update(jsgl)){
    	  String jsmc = data.getStrValue(MbXtglJsgl.JSMC);
          LogUtils logUtils = new LogUtils();
          String desc = jsmc+LogUtils.MbXtglYhxx_UPDATE_DESC;
          logUtils.addLog(String.valueOf(LogUtils.type_update), LogUtils.model_yhgl, contributor, desc);
        result.add(Status.SATUS,Status.OK);
      }else{
        throw new Exception("更新信息失败！");
      }
    } catch (Exception e) {
      e.printStackTrace();
      logger.error(e.getMessage());
      result.add(Status.SATUS, Status.FAILED);
    }
    return result;
  }
  /**
   * Description: 删除角色及角色权限关系
   * @param request
   * @param response
   * @param data
   * @return
   */
  @rquestMethod(MethodNote = ReqMode.All)
  @TransAnnotation(isTrans=true)
  public Record delete(HttpServletRequest request, HttpServletResponse response, Record data) {
    Record result = new Record();
    try {
      MbXtglJsglDao dao = new MbXtglJsglDao();
      Record jsgl = dao.getById(data.getIntValue("zdbh"));
      if (jsgl != null) {
        jsgl.add(MbXtglJsgl.JSZT, 0);
        dao.update(jsgl);
        String jsbm = jsgl.getStrValue(MbXtglJsgl.JSBM);
        MbXtglJsqxgxDao qdao = new MbXtglJsqxgxDao();
        List<Record> list = qdao.getBySql("select * from mb_xtgl_jsqxgx where jsbm='" + jsbm + "'");
        qdao.delete(list);        
      }
      result.add(Status.SATUS,Status.OK);
    } catch (Exception e) {
      e.printStackTrace();
      logger.error(e.getMessage());
      // 事务回滚
      result.add(Status.SATUS, Status.FAILED);
    }
    return result;
  }

  public List getQxlistByUserid(String userid){
    String sql = "select jsdh.dhbm,js.zdbh jsbm,qxgl.* from mb_xtgl_ryjsfp fp "
        + "left join mb_xtgl_jsgl js on fp.jsbm=js.zdbh "
        + "left join mb_xtgl_jsqxgx qxgx on js.zdbh=qxgx.jsbm "
        + "left join mb_xtgl_qxgl qxgl on qxgx.qxbm = qxgl.zdbh "
        + "left join mb_xtgl_jsdhgl jsdh on js.zdbh=jsdh.jsbm "
        + "where qxzt=1 and fp.rybm =  "+userid+" ";
        //+ "and fp.jsbm "+jsbm   ;         
        List<Record> list_ = new BaseDao().getBySql(sql);
        
        return list_;
  }

  public Record checkQxDup(HttpServletRequest request, HttpServletResponse response, Record data){
    Record result = new Record();
    String userids = data.getStrValue("userids");
    String dhbm = data.getStrValue("dhbm");
    if(userids==null||userids.length()==0){
      result.add(Status.SATUS, Status.FAILED);
      return result;
    }

    String sql = "select * from ( "
        + "select count(*) n,qxgl.qxbm "
        + "from mb_xtgl_ryjsfp fp "
        + "left join mb_xtgl_jsgl js on fp.jsbm=js.jsbm "
        + "left join mb_xtgl_jsqxgx qxgx on js.jsbm=qxgx.jsbm "
        + "left join mb_xtgl_qxgl qxgl on qxgx.qxbm = qxgl.qxbm "
        + "where fp.rybm in ("+userids+") and qxgx.jsbm in (select jsbm from mb_xtgl_jsdhgl where dhbm='"+dhbm+"' )"
        + "GROUP BY qxgl.qxbm "
        + ") a where n>1";
    List<Record> list_ = new BaseDao().getBySql(sql);
    if(list_!=null&&!list_.isEmpty()){
      result.add(Status.SATUS, Status.OK);
      result.add(Status.MSG, "true");
    }else{
      result.add(Status.SATUS, Status.OK);
      result.add(Status.MSG, "false");
    }
    return result;
  }
}
